<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('淘宝物料')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <tbMnMaterialOptional-modal ref="modalForm" @ok="modalFormOk"></tbMnMaterialOptional-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import TbMnMaterialOptionalModal from './modules/TbMnMaterialOptionalModal'

  export default {
    name: "TbMnMaterialOptionalList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      TbMnMaterialOptionalModal
    },
    data () {
      return {
        description: '淘宝物料管理页面',
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          // } 
          // ,
          {
            title:'总销售量',
            align:"center",
            dataIndex: 'tkTotalSales'
          },
          {
            title:'总支出佣金',
            align:"center",
            dataIndex: 'tkTotalCommi'
          },
     
          {
            title:'numIid',
            align:"center",
            dataIndex: 'numIid'
          },
          {
            title:'标题',
            align:"center",
            dataIndex: 'title',
            customRender: (text) => {
               if(text.length>5){
                 return <a href="javascript:;" title={text} > {text.substring(0,5)} </a>
               }else{
                 return text;
               }
            }

              // <a-tooltip>
          },
          {
            title:'图片',
            align:"center",
            dataIndex: 'pictUrl',
              customRender: (text) => {
               return <img  src={text} height='60' weight='60' />
      
            }
          },
       
          {
            title:'一口价',
            align:"center",
            dataIndex: 'reservePrice'
          },
          {
            title:'在售价',
            align:"center",
            dataIndex: 'zkFinalPrice'
          },
          // {
          //   title:'userType',
          //   align:"center",
          //   dataIndex: 'userType'
          // },
          {
            title:'地铺地址',
            align:"center",
            dataIndex: 'provcity'
          },
          // {
          //   title:'includeMkt',
          //   align:"center",
          //   dataIndex: 'includeMkt'
          // },
          // {
          //   title:'includeDxjh',
          //   align:"center",
          //   dataIndex: 'includeDxjh'
          // },
          {
            title:'分成比率',
            align:"center",
            dataIndex: 'commissionRate'
          },
          {
            title:'30天销量',
            align:"center",
            dataIndex: 'volume'
          },
          {
            title:'返佣总理',
            align:"center",
            dataIndex: 'couponTotalCount'
          },
          {
            title:'返佣剩余数量',
            align:"center",
            dataIndex: 'couponRemainCount'
          },
          {
            title:'返佣信息',
            align:"center",
            dataIndex: 'couponInfo'
          },
          // { 
          //   title:'营销计划',
          //   align:"center",
          //   dataIndex: 'commissionType'
          // },
          // {
          //   title:'店铺标题',
          //   align:"center",
          //   dataIndex: 'shopTitle'
          // },
          // {
          //   title:'店铺简介',
          //   align:"center",
          //   dataIndex: 'shopDsr'
          // },
          // {
          //   title:'couponShareUrl',
          //   align:"center",
          //   dataIndex: 'couponShareUrl',
          //        customRender: (text) => {
          //      return <a  src={text} height='60' weight='60' >宝贝链接</a>
      
          //   }
          // },
          // {
          //   title:'url',
          //   align:"center",
          //   dataIndex: 'url',
          //      dataIndex: 'couponShareUrl',
          //        customRender: (text) => {
          //      return <a  src={text} height='60' weight='60' >宝贝推广链接</a>
      
          //   }
          // },
          // {
          //   title:'levelOneCategoryName', 
          //   align:"center",
          //   dataIndex: 'levelOneCategoryName'
          // },
          // {
          //   title:'levelOneCategoryId',
          //   align:"center",
          //   dataIndex: 'levelOneCategoryId'
          // },
          // {
          //   title:'categoryName',
          //   align:"center",
          //   dataIndex: 'categoryName'
          // },
          // {
          //   title:'categoryId',
          //   align:"center",
          //   dataIndex: 'categoryId'
          // },
          // {
          //   title:'shortTitle',
          //   align:"center",
          //   dataIndex: 'shortTitle'
          // },
          // {
          //   title:'whiteImage',
          //   align:"center",
          //   dataIndex: 'whiteImage'
          // },
          // {
          //   title:'oetime',
          //   align:"center",
          //   dataIndex: 'oetime'
          // },
          // {
          //   title:'ostime',
          //   align:"center",
          //   dataIndex: 'ostime'
          // },
          // {
          //   title:'jddNum',
          //   align:"center",
          //   dataIndex: 'jddNum'
          // },
          {
            title:'推荐简介',
            align:"center",
            dataIndex: 'jddPrice',
                 customRender: (text) => {
               return <a href="javascript:;" title={text} > {text.substring(0,5)} </a>
      
            }
          },
          {
            title:'token',
            align:"center",
            dataIndex: 'token'
          },
          {
            title:'返佣金额',
            align:"center",
            dataIndex: 'couponAmount'
          },
          // {
          //   title:'sort',
          //   align:"center",
          //   dataIndex: 'sort'
          // },
          // {
          //   title:'type',
          //   align:"center",
          //   dataIndex: 'type'
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/mall/tbMnMaterialOptional/list",
          delete: "/mall/tbMnMaterialOptional/delete",
          deleteBatch: "/mall/tbMnMaterialOptional/deleteBatch",
          exportXlsUrl: "/mall/tbMnMaterialOptional/exportXls",
          importExcelUrl: "mall/tbMnMaterialOptional/importExcel",
        },
        dictOptions:{},
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>